package com.yugao.fintech.antelope.shop.manager;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yugao.fintech.antelope.base.model.constants.TenantCons;
import com.yugao.fintech.antelope.base.model.module.tenant.TenantContextHolder;
import com.yugao.fintech.antelope.shop.mapper.SkuStockMapper;
import com.yugao.fintech.antelope.shop.model.entity.SkuStock;
import com.yugao.fintech.antelope.base.tenant.core.utils.TenantUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

/**
 * 商品sku 仓储层
 *

 */
@Slf4j
@Repository
public class SkuStockManager extends ServiceImpl<SkuStockMapper, SkuStock>
    implements IService<SkuStock> {

    public void deleteByGoodsId(Long goodsId) {
        TenantUtils.execute(
                TenantCons.Type.MAIN,
                TenantContextHolder.get().getTenantId(), // 这里设置成当前租户id原因是, 只有主租户才能删除
                () -> this.remove(SkuStock.lqw().eq(SkuStock::getGoodsId, goodsId))
        );
    }
}
